home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97a.txt / 000063_icon-group-sender _Mon Mar 3 20:29:10 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Tue, 4 Mar 1997 08:22:55 MST
  2. Date: Mon, 3 Mar 1997 20:29:10 -0600 (CST)
  3. From: "Chris D. Tenaglia" <cdt@post.its.mcw.edu>
  4. To: Mark Kot <kot@buteo.math.utk.edu>
  5. Cc: icon-group@cs.arizona.edu
  6. Subject: Re: reading reals
  7. In-Reply-To: <5ff37v$r3n$1@gaia.ns.utk.edu>
  8. Message-Id: <Pine.ULT.3.90.970303202232.23683A-100000@post.its.mcw.edu>
  9. Mime-Version: 1.0
  10. Content-Type: TEXT/PLAIN; charset=US-ASCII
  11. Errors-To: icon-group-errors@cs.arizona.edu
  12. Status: RO
  13. Content-Length: 1251
  14.  
  15. #
  16. # not much error checking done
  17. # I include the other procedures as examples too
  18. #
  19. procedure main()
  20.   line := input("Enter A & B>")
  21.   a    := real(parse(line,' \t')[1])
  22.   b    := real(parse(line,' \t')[2])
  23.   write(real(a + b))
  24.   end
  25.  
  26. #
  27. # prompt for an input string
  28. #
  29. procedure input(prompt)
  30.   writes(prompt)
  31.   return read()
  32.   end
  33.  
  34. #
  35. # parse a string into a list with respec to a delimiter
  36. #
  37. procedure parse(line,delims)
  38.   static chars
  39.   chars  := &cset -- delims
  40.   tokens := []
  41.   line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
  42.   return tokens
  43.   end
  44.  
  45. Chris Tenaglia   (system manager)     |  cdt@post.its.mcw.edu
  46. Medical College of Wisconsin          |
  47. 8701 W. Watertown Plank Rd.           |  Ce que vous voyez est
  48. Milwaukee, WI 53226   (414)456-8765   |  ce que vous obtenez !
  49.  
  50. On 3 Mar 1997, Mark Kot wrote:
  51.  
  52. > Date: 3 Mar 1997 17:54:07 GMT
  53. > From: Mark Kot <kot@buteo.math.utk.edu>
  54. > To: icon-group@cs.arizona.edu
  55. > Subject: reading reals
  56. >     What is the Icon analog to the C
  57. > programming instruction
  58. >     scanf("%f%f", &x, &y);   ?
  59. > That is, what is the simplest (or most standard)
  60. > way to read two real numbers (with intervening
  61. > and/or preceding white space) from a line of
  62. > input in Icon ?
  63. >     Many thanks !
  64.